import { resolve } from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import svgLoader from 'vite-svg-loader';
// import json5Plugin from 'vite-plugin-json5';

// const target = 'http://bzsite.dev.proxima-ai.com/ry';
// const target = 'http://172.16.18.250:8091';

export default defineConfig({
  plugins: [vue(), vueJsx(), svgLoader({ svgoConfig: {} })],
  resolve: {
    alias: [
      {
        find: '@',
        replacement: resolve(__dirname, '../src'),
      },
      {
        find: 'assets',
        replacement: resolve(__dirname, '../src/assets'),
      },
      {
        find: 'vue-i18n',
        replacement: 'vue-i18n/dist/vue-i18n.cjs.js', // Resolve the i18n warning issue
      },
      {
        find: 'vue',
        replacement: 'vue/dist/vue.esm-bundler.js', // compile template
      },
    ],
    extensions: ['.ts', '.js'],
  },
  define: {
    'process.env': {},
  },
  css: {
    preprocessorOptions: {
      less: {
        charset: false,
        modifyVars: {
          hack: `true; @import (reference) "${resolve(
            'src/assets/style/global.less'
          )}";`,
        },
        javascriptEnabled: true,
      },
    },
  },
  publicDir: "public",
  optimizeDeps: {
    include: ['element-plus/es/locale/lang/zh-cn']
  }
});
